package com.bfd.archetype.exception;

import com.bfd.archetype.common.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @program: GlobalExceptionResolver
 * @description: 全局异常
 * @author: guangyu.you
 * @create: 2020-10-15 17:12
 **/
@ControllerAdvice
@Slf4j
public class GlobalExceptionResolver {


    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public JsonResult exceptionHandler(HttpServletRequest req, Exception exception) {
        exception.printStackTrace();
        log.error("xxxx异常", exception);
        return JsonResult.errorMsg(exception.getMessage());
    }



}
